import 'package:flutter/material.dart';
import 'package:flutter_dwh5/pages/cart/cart.dart';
import 'package:flutter_dwh5/pages/home/home.dart';
import 'package:flutter_dwh5/pages/my/my.dart';
import 'package:flutter_dwh5/pages/server/server.dart';

class Index extends StatefulWidget {
  @override
  State<Index> createState() => _IndexState();
}

class _IndexState extends State<Index> {
  List<Widget> tabbar = [Home(), Cart(), Server(), My()];
  List<BottomNavigationBarItem> barItemList = [
    BottomNavigationBarItem(icon: Icon(Icons.home), label: '首页'),
    BottomNavigationBarItem(icon: Icon(Icons.card_giftcard), label: '购物车'),
    BottomNavigationBarItem(
        icon: Icon(Icons.self_improvement_rounded), label: '客服'),
    BottomNavigationBarItem(icon: Icon(Icons.account_circle), label: '我的'),
  ];
  int _currentIndex = 0;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      // appBar: AppBar(
      //   title: Text('多威商城'),
      //   elevation: 0,
      //   centerTitle: true,
      // ),
      body: tabbar[_currentIndex],
      bottomNavigationBar: BottomNavigationBar(
        items: barItemList,
        type: BottomNavigationBarType.fixed,
        unselectedItemColor: Colors.grey,
        selectedItemColor: Colors.black,
        currentIndex: this._currentIndex,
        onTap: (int index) {
          setState(() {
            this._currentIndex = index;
          });
        },
      ),
    );
  }
}
